-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add protect & unprotect workunit to WU context menu #367
Conversation
@GordonSmith for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you opened a PR or Ticket for the Viz repo?
Can you remove the submenu and only show "Protect" when WU is not protected and show "Unprotect" when the WU is protected?
I did create a ticket (not an issue) for this. |
@GordonSmith will make the changes you requested. |
@GordonSmith come to think of it, I don't believe you can dynamically change the menu. You can only gray things out. So I suggest we gray the appropriate one out. |
It is a little bit tricky - but if you search the code base for:
You can see how I worked around the limitation. |
@GordonSmith the setContext command is a global command and works in the case of isAllWorkunits and isMyWorkunits because they are globals that pertain to all tree nodes. The protect only applies to a single node so it can't be used in the same way. It will have to be grayed out using viewItem because viewItem is specific to each tree node. |
Sounds plausible. |
04d60d5
to
d56fad6
Compare
@dehilsterlexis you need to
|
d56fad6
to
911bd36
Compare
@GordonSmith for review |
src/ecl/eclWatchTree.ts
Outdated
@@ -93,6 +93,16 @@ export class ECLWatchTree extends Tree { | |||
wuNode.delete(); | |||
}); | |||
|
|||
vscode.commands.registerCommand("hpccPlatform.protectWU", (wuNode: ECLWUNode) => { | |||
wuNode.protect(); | |||
this.refresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this refresh is needed? If it is, it should wait for the "protect" to complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you need it or the menu doesn't update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.refresh
here.
src/ecl/eclWatchTree.ts
Outdated
|
||
vscode.commands.registerCommand("hpccPlatform.unprotectWU", (wuNode: ECLWUNode) => { | ||
wuNode.unprotect(); | ||
this.refresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this refresh is needed? If it is, it should wait for the "unprotect" to complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you need it or the menu doesn't update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.refresh
here.
src/ecl/eclWatchTree.ts
Outdated
} | ||
|
||
unprotect() { | ||
this._wu.unprotect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should refresh the tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that would call it twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
this._wu.unprotect().then(() => this._tree.refresh());
src/ecl/eclWatchTree.ts
Outdated
@@ -421,7 +439,8 @@ export class ECLWUNode extends Item<ECLWatchTree> { | |||
} | |||
|
|||
contextValue(): string { | |||
return this._wu.isComplete() ? "ECLWUNodeComplete" : "ECLWUNode"; | |||
const prot = this._wu.Protected ? "Protected" : "Unprotected"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to ECLWUNodeProtected
and ECLWUNode
respectivly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons for this change:
- Consistency
- Avoid a context clash with other extensions (not very likely, but...)
911bd36
to
77b7628
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update ECLWUNode.getLabel
to
getLabel(): string {
let primary = this._wu.Wuid;
const extras: string[] = [];
if (!this._wu.isComplete() || this._wu.isDeleted()) extras.push(this._wu.State);
if (!this._tree._myWorkunits && this._wu.Owner) extras.push(this._wu.Owner);
if (this._wu.Jobname) {
primary = this._wu.Jobname;
extras.push(this._wu.Wuid);
}
if (this._wu.Protected) {
extras.push("Protected");
}
return extras.length ? `${primary} (${extras.join(", ")})` : primary;
}
And / or update the icon to show the lock symbol?
src/ecl/eclWatchTree.ts
Outdated
@@ -93,6 +93,16 @@ export class ECLWatchTree extends Tree { | |||
wuNode.delete(); | |||
}); | |||
|
|||
vscode.commands.registerCommand("hpccPlatform.protectWU", (wuNode: ECLWUNode) => { | |||
wuNode.protect(); | |||
this.refresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.refresh
here.
src/ecl/eclWatchTree.ts
Outdated
|
||
vscode.commands.registerCommand("hpccPlatform.unprotectWU", (wuNode: ECLWUNode) => { | ||
wuNode.unprotect(); | ||
this.refresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.refresh
here.
src/ecl/eclWatchTree.ts
Outdated
} | ||
|
||
unprotect() { | ||
this._wu.unprotect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
this._wu.unprotect().then(() => this._tree.refresh());
src/ecl/eclWatchTree.ts
Outdated
@@ -421,7 +439,8 @@ export class ECLWUNode extends Item<ECLWatchTree> { | |||
} | |||
|
|||
contextValue(): string { | |||
return this._wu.isComplete() ? "ECLWUNodeComplete" : "ECLWUNode"; | |||
const prot = this._wu.Protected ? "Protected" : "Unprotected"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump
77b7628
to
ae99d35
Compare
src/ecl/eclWatchTree.ts
Outdated
@@ -421,7 +439,8 @@ export class ECLWUNode extends Item<ECLWatchTree> { | |||
} | |||
|
|||
contextValue(): string { | |||
return this._wu.isComplete() ? "ECLWUNodeComplete" : "ECLWUNode"; | |||
const prot = this._wu.Protected ? "Protected" : "Unprotected"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons for this change:
- Consistency
- Avoid a context clash with other extensions (not very likely, but...)
ae99d35
to
b9c0924
Compare
@GordonSmith for review. The caret in the when clause does not seem to work in this particular when clauses so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment WRT to getLabel.
b9c0924
to
d3de696
Compare
@GordonSmith for review |
@GordonSmith this is most likely failing because of a version problem. Any suggestions? |
You need to:
And then commit both the package-lock.json and the package.json. Did you test its working? |
3adb820
to
6abd006
Compare
39a2571
to
938114e
Compare
PR tests failing... |
@GordonSmith yes I know. I can't seem to get rid of some files in the PR that should not be there. Usually this is fixed by rebasing. |
5cea82a
to
0b98c93
Compare
@GordonSmith for review |
package.json
Outdated
"command": "hpccPlatform.protectWU", | ||
"category": "ECL", | ||
"title": "%Protect Workunit%", | ||
"enablement": "viewItem =~ /ECLWUNodeComplete/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to protect a WU while its running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to protect a WU while its running?
package.json
Outdated
"command": "hpccPlatform.unprotectWU", | ||
"category": "ECL", | ||
"title": "%Unprotect Workunit%", | ||
"enablement": "viewItem =~ /ECLWUNodeComplete/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to unprotect a WU while its running?
src/ecl/eclWatchTree.ts
Outdated
|
||
getDescription(): string { | ||
return this._result.Value ?? ""; | ||
return `${this._result.Name}: ${this._result.Value}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the label + description approach.
d44f957
to
b30e763
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WU Can be protected / unprotected while running
@dehilsterlexis some comments and needs a rebase. |
4cf6813
to
088c789
Compare
@GordonSmith for review |
package.json
Outdated
"command": "hpccPlatform.protectWU", | ||
"category": "ECL", | ||
"title": "%Protect Workunit%", | ||
"enablement": "viewItem =~ /ECLWUNodeComplete/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to protect a WU while its running?
088c789
to
a425c86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to protect and unprotect a WU before its completed.
Signed-off-by: David de Hilster <[email protected]>
a425c86
to
a249bf3
Compare
@GordonSmith now functions before completed. For review. |
This will require the adding of two functions to the Workunit class in the comms code in the Visualization repository: https://github.com/hpcc-systems/Visualization/blob/trunk/packages/comms/src/ecl/workunit.ts